# 喜欢的数 　编写一个程序，提示用户输入喜欢的
# 数，并使用json.dump() 将这个数存储到文件中。再编写一
# 个程序，从文件中读取这个值，并打印如下所示的消息。
# I know your favorite number! It's _____.

import json
def store_favorite_number():
	"""提示用户输入喜欢的数字并存储到文件中"""

	favorite_number = input("What is your favorite number? ")
	filename = "favorite_number.json"
	with open(filename, 'w') as f:
		json.dump(favorite_number, f)
	return favorite_number

def show_favorite_number():
	"""读取存储在json文件中用户喜欢的数并展示出来"""
	filename = 'favorite_number.json'
	with open(filename) as f:
		favorite_number = json.load(f)
		print(f"I know your favorite number! It's {favorite_number}.")

store_favorite_number()
show_favorite_number()
